/**
 * 不死神兔
 */
public class Demo09 {
    public static void main(String[] args) {
        //定义一个int类型的数组, 数组名叫: a, 数组的长度是12.
        System.out.println(method01(12));
        //赋值
        //方法2 使用递归求解
        System.out.println(method02(11));
    }

    public static int method01(int x) {
        if (x < 0)
            return -1;
        if (x <= 2)
            return 1;
        int[] a = new int[x];
        a[0] = 1;
        a[1] = 1;
        //for循环求解
        for (int i = 2; i < x; i++) {
            a[i] = a[i - 1] + a[i - 2];
        }
        return a[x - 1];
    }

    //静态方法递归求解
    public static int method02(int x) {
        if (x < 0)
            return -1;
        if (x == 1 || x == 0)
            return 1;
        else
            return method02(x - 1) + method02(x - 2);
    }
}
